<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript" src="/${initParam.context_root }/script/jquery.js"></script>
<script type="text/javascript">
	
	$(document).ready(function(){
		
		$("#getMessage").on("click", function(){
			$.ajax({
				url:"/${initParam.context_root }/chatting/get.do"
				, type:"GET"
				, data:"friendId=id-02"
				, dataType:"JSON"
				, error:function(){
					alert("메세지없어");
				}
				, success:function(json){//$.ajax에서 dataType을 JSON으로 주면 서버에서 넘어온다
					//alert(json);
					//alert(json.member.id + ", " + json.member.name + ", " + json.member.email);
					//$("#layer").html(json.member.id+"-" + json.member.name+"-"+json.member.email);
					//$("#layer").text(json.member.id+"-" + json.member.name+"-"+json.member.email);
					var str = JSON.stringify(json);
					$("#output").val(str);
					alert(JSONtoString(json));
					
				}
				
			});
		});
	});
</script>
<body>

<form action="/${initParam.context_root}/chatting/send.do" method="post">
	<input type="text" name="fromId" value="id를입력">
	<input type="text" name="message" value="메세지입력">
	<input type="hidden" name="toId" value="id-02">
	<input type="submit" value="전송!">
</form>
<br><br>
<form>	
<input type="button" value="messageGet!" id="getMessage">
</form>

<input type="text" value="Empty" id="output">
<div id="layer"></div>

</body>
</html>
